using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;

namespace Unitins.Component.Repository.Sepsi
{
    public class ProfessorManager : Unitins.Component.ComponentMaster.ManagerMaster<Professor, ProfessorCollection>
    {
        [DataObjectMethod(DataObjectMethodType.Select)]
        public static Professor Buscar(Int64 idProfessor)
        {
            return Buscar(idProfessor, ProfessorAttribute.IdProfessor);
        }

        [DataObjectMethod(DataObjectMethodType.Select)]
        public static ProfessorCollection Filtro(string valor, int campoFiltro, int campoOrdenacao, string tipoOrdenacao)
        {
            PersistenceLayer.DataBase.Parameter.PLSearchMounter<Professor> myMounter = new Unitins.Component.PersistenceLayer.DataBase.Parameter.PLSearchMounter<Professor>();

            Unitins.Component.PersistenceLayer.DataBase.Parameter.PLSearchMounterSortType mySortType = Unitins.Component.PersistenceLayer.DataBase.Parameter.PLSearchMounterSortType.Ascending;

            if(tipoOrdenacao.ToLower().Equals("desc"))
                mySortType = Unitins.Component.PersistenceLayer.DataBase.Parameter.PLSearchMounterSortType.Descending;

            myMounter.Parameters.Add(new Unitins.Component.PersistenceLayer.DataBase.Parameter.PLSearchMounterParameter((ProfessorAttribute)campoFiltro, valor, Unitins.Component.PersistenceLayer.DataBase.Parameter.PLSearchMounterCompareType.Like, Unitins.Component.PersistenceLayer.DataBase.Parameter.PLSearchMounterConditionType.And));
            myMounter.SortCollection.Add(new Unitins.Component.PersistenceLayer.DataBase.Parameter.PLSearchMounterSort((ProfessorAttribute)campoOrdenacao, mySortType));

            return PersistenceLayer.Manager.SearchAll<Professor, ProfessorCollection>(myMounter);
        }
    }
}
